﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;

namespace Windows8Accelerator.Core.Xaml.Controls
{
    public class SuperDataTemplateSelector : DataTemplateSelector
    {
        private Func<object, Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.DataTemplate> Selector;
        
        public SuperDataTemplateSelector(Func<object, Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.DataTemplate> selector)
        {
            Selector = selector;
        }

        protected override Windows.UI.Xaml.DataTemplate SelectTemplateCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            return Selector(item, container) ?? base.SelectTemplateCore(item, container);
        }
    }
}
